
      
<h1 class="mume-header" id="promise%E5%BC%82%E6%AD%A5async%E5%87%BD%E6%95%B0%E5%BC%82%E6%AD%A5">Promise&#x2260;&#x5F02;&#x6B65;&#xFF0C;async&#x51FD;&#x6570;&#x2260;&#x5F02;&#x6B65;</h1>

<blockquote>
<p>&#x672C;&#x6587;&#x5E76;&#x4E0D;&#x63D0;&#x4F9B;<strong>Promise</strong>&#x548C;<strong>async&#x51FD;&#x6570;</strong>&#x7684;&#x7528;&#x6CD5;&#x8BF4;&#x660E;&#xFF0C;&#x4EC5;&#x5C1D;&#x8BD5;&#x901A;&#x8FC7;&#x7B80;&#x5355;&#x7684;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5BF9;<strong>Promise</strong>&#x548C;<strong>async&#x51FD;&#x6570;</strong>&#x7684;&#x6982;&#x5FF5;&#x548C;&#x672C;&#x8D28;&#x4F5C;&#x7B80;&#x5355;&#x68B3;&#x7406;&#x3002;</p>
</blockquote>
<p><strong>Promise</strong>&#x548C;<strong>async&#x51FD;&#x6570;</strong>&#x662F;&#x4E3A;&#x5F02;&#x6B65;&#x800C;&#x751F;&#xFF0C;&#x4F46;&#x662F;&#xFF0C;&#x5982;&#x679C;&#x5C06;&#x5B83;&#x4EEC;&#x548C;&#x5F02;&#x6B65;&#x5212;&#x7B49;&#x53F7;&#xFF0C;&#x53EF;&#x80FD;&#x5C31;&#x6709;&#x95EE;&#x9898;&#x4E86;&#x3002;</p>
<h2 class="mume-header" id="%E5%85%88%E8%AF%B4promise">&#x5148;&#x8BF4;Promise</h2>

<h4 class="mume-header" id="%E5%AE%9A%E4%B9%89-promise">&#x5B9A;&#x4E49; promise</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// &#x5B9A;&#x4E49; promise  </span>
<span class="token keyword">const</span> promise <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> reject<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>  
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;promise start&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  

  <span class="token comment">// &#x7528;&#x4E00;&#x4E2A;for&#x5FAA;&#x73AF;&#x7B80;&#x5355;&#x6A21;&#x62DF;&#x4E00;&#x4E0B;&#x5927;&#x6570;&#x636E;&#x91CF;&#x5904;&#x7406;  </span>
  <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> index <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">;</span> index<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>  
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;promise process &apos;</span> <span class="token operator">+</span> index<span class="token punctuation">)</span><span class="token punctuation">;</span>    
  <span class="token punctuation">}</span>  

  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;promise end&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;1&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token comment">// &#x6309;&#x7167;&#x60EF;&#x4F8B;&#xFF0C;then &#x4E00;&#x4E0B;  </span>
promise<span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;Promise done&apos;</span><span class="token punctuation">)</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;2&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  

</pre><p>&#x8FD0;&#x884C;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>promise start  
promise process 0  
promise process 1  
promise process 2  
promise process 3  
promise process 4  
promise end  
1  
2  
</code></pre><p>&#x5728;&#x8FD9;&#x4E2A;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x4E2D;&#xFF0C;&#x5B9A;&#x4E49;Promise&#x7684;&#x4EE3;&#x7801;&#x5728;&#x5B9A;&#x4E49;&#x65F6;&#x5C31;&#x5DF2;&#x7ECF;&#x540C;&#x6B65;&#x6267;&#x884C;&#x4E86;&#xFF0C;&#x540E;&#x9762;&#x7684;then&#x8C03;&#x7528;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x8F93;&#x51FA;&#x3002;<br>
A:&quot;&#x8BF4;&#x660E;&#x4EC0;&#x4E48;&#xFF1F;&#x8BF4;&#x660E;Promise&#x4E0D;&#x662F;&#x5F02;&#x6B65;&#x7684;&#xFF0C;&#x5B83;&#x7684;&#x5B9A;&#x4E49;&#x548C;&#x6267;&#x884C;&#x90FD;&#x4E0D;&#x662F;&#x5F02;&#x6B65;&#x7684;&#xFF01;&quot;<br>
B:&#x201C;&#x4F60;&#x80E1;&#x8BF4;&#xFF0C;&#x4F60;&#x8FDE;resolve&#x90FD;&#x6CA1;&#x7528;&#xFF01;&#x201D;</p>
<h4 class="mume-header" id="%E5%8A%A0%E5%85%A5resolve">&#x52A0;&#x5165;resolve</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">const</span> promise <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> reject<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>  
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;promise start&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  

  <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> index <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">;</span> index<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>  
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;promise process &apos;</span> <span class="token operator">+</span> index<span class="token punctuation">)</span><span class="token punctuation">;</span>    
  <span class="token punctuation">}</span>  

  <span class="token comment">// &#x7528;resolve&#x629B;&#x51FA;&#x4E00;&#x4E2A;&#x503C;  </span>
  <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token string">&apos;promise done&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  

  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;promise end&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;1&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token comment">// then &#x7684;&#x56DE;&#x8C03;&#x51FD;&#x6570;&#x4E2D;&#x63A5;&#x5230;resolve&#x629B;&#x51FA;&#x7684;&#x503C;&#x5E76;&#x8F93;&#x51FA;&#x5230;&#x63A7;&#x5236;&#x53F0;  </span>
promise<span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>v<span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>v<span class="token punctuation">)</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;2&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
</pre><p>&#x8FD0;&#x884C;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>promise start  
Promise0  
Promise1  
Promise2  
Promise3  
Promise4  
promise end  
1  
2  
promise done  
</code></pre><p>B:&#x201C;&#x5F02;&#x6B65;&#x4E86;&#x5427;&#xFF1F;&#x5F02;&#x6B65;&#x4E86;&#x5427;&#xFF1F;&#x2018;promise done&#x2019;&#x5728;2&#x540E;&#x9762;&#x51FA;&#x6765;&#x7684;&#x3002;&#x201D;<br>
A:&#x201C;&#x6574;&#x4E2A;promise&#x6267;&#x884C;&#x8FC7;&#x7A0B;&#x662F;&#x540C;&#x6B65;&#x7684;&#xFF0C;&#x628A;&#x8FD4;&#x56DE;&#x503C;&#x5F02;&#x6B65;&#x51FA;&#x6765;&#xFF0C;&#x9876;&#x4E2A;X&#x7528;&#xFF01;&#x201D;<br>
B:&quot;......&quot;<br>
B:&quot;&#x6211;&#x60F3;&#x8D77;&#x6765;&#x4E86;&#xFF0C;&#x962E;&#x5927;&#x4FA0;&#x8BF4;&#xFF1A;&#x201C;Promise&#x53EA;&#x662F;&#x4E2A;<strong>&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x5BB9;&#x5668;</strong>&#x201D;&#xFF0C;&#x6240;&#x4EE5;&#x4F60;&#x8981;&#x5728;Promise&#x4E2D;&#x88C5;&#x4E2A;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x8FDB;&#x53BB;&#x624D;&#x884C;&#xFF01;&quot;</p>
<h4 class="mume-header" id="%E5%A1%9E%E4%B8%AA%E5%BC%82%E6%AD%A5%E6%93%8D%E4%BD%9C">&#x585E;&#x4E2A;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">const</span> promise <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> reject<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>  
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;promise start&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  

  <span class="token comment">// &#x8FD9;&#x4E2A;setTimeout&#x5C31;&#x662F;&#x585E;&#x8FDB;&#x6765;&#x7684;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;  </span>
  <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>  
    
    <span class="token comment">// &#x539F;&#x6765;&#x7684;&#x5927;&#x6570;&#x636E;&#x91CF;&#x5904;&#x7406;&#x8BED;&#x53E5;&#x79FB;&#x5230;setTimeout&#x4E2D;&#x6765;  </span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> index <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">;</span> index<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>  
      console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;Promise&apos;</span> <span class="token operator">+</span> index<span class="token punctuation">)</span><span class="token punctuation">;</span>    
    <span class="token punctuation">}</span>  

    <span class="token comment">// &#x539F;&#x6765;&#x7684;&#x7ED3;&#x679C;&#x8FD4;&#x56DE;&#x8BED;&#x53E5;&#x4E5F;&#x79FB;&#x5230;setTimeout&#x4E2D;&#x6765;  </span>
    <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token string">&apos;promise done&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  

  <span class="token punctuation">}</span><span class="token punctuation">,</span><span class="token number">1000</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
  
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;promise end&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  
</pre><p>&#x8FD0;&#x884C;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>promise start  
promise end  
1  
2  
Promise0  
Promise1  
Promise2  
Promise3  
Promise4  
promise done  
</code></pre><p>B:&#x201C;&#x5F02;&#x6B65;&#x4E86;&#x5427;&#xFF1F;&#x5F02;&#x6B65;&#x4E86;&#x5427;&#xFF1F;&#x6574;&#x4E2A;&#x4E1A;&#x52A1;&#x903B;&#x8F91;&#x90FD;&#x662F;&#x5728;2&#x540E;&#x9762;&#x51FA;&#x6765;&#x7684;&#x3002;&#x201D;<br>
A:&#x201C;&#x662F;&#x5F02;&#x6B65;&#x4E86;&#xFF0C;&#x4F46;&#x662F;setTimeout&#x672C;&#x8EAB;&#x5C31;&#x6267;&#x884C;&#x4E86;&#x4E00;&#x4E2A;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#xFF0C;&#x5E72;&#x561B;&#x8981;&#x591A;&#x6B64;&#x4E00;&#x4E3E;&#x7684;&#x628A;&#x5B83;&#x585E;&#x8FDB;Promise&#x91CC;&#x5462;&#xFF1F;&#x201D;<br>
B:&#x201C;......&#x201D;</p>
<h4 class="mume-header" id="%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E7%94%A8promise">&#x4E3A;&#x4EC0;&#x4E48;&#x8981;&#x7528;Promise</h4>

<p>&#x6211;&#x4EEC;&#x5728;&#x5F02;&#x6B65;&#x8C03;&#x7528;&#x65F6;&#x7ECF;&#x5E38;&#x4F1A;&#x9047;&#x5230;&quot;&#x540E;&#x4E00;&#x4E2A;&#x5F02;&#x6B65;&#x8C03;&#x7528;&#x7684;&#x53C2;&#x6570;&#x662F;&#x524D;&#x4E00;&#x4E2A;&#x5F02;&#x6B65;&#x8C03;&#x7528;&#x7684;&#x7ED3;&#x679C;&quot;&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x4F20;&#x7EDF;&#x65B9;&#x5F0F;&#x5199;&#x51FA;&#x6765;&#x662F;&#x8FD9;&#x6837;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token function">a</span><span class="token punctuation">(</span>&#x53C2;&#x6570;<span class="token punctuation">,</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
  <span class="token function">b</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>a&#xFF0C;<span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
    <span class="token comment">//.....  </span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  
</pre><p>a&#x548C;b&#x5D4C;&#x5957;&#x8D77;&#x6765;&#x4E86;&#xFF0C;&#x5982;&#x679C;&#x5173;&#x8054;&#x5173;&#x7CFB;&#x66F4;&#x591A;&#xFF0C;&#x53EF;&#x80FD;&#x4F1A;&#x51FA;&#x73B0;&#x8FD9;&#x79CD;&#x60C5;&#x51B5;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token function">a</span><span class="token punctuation">(</span>&#x53C2;&#x6570;<span class="token punctuation">,</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
  <span class="token function">b</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>a&#xFF0C;<span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
    <span class="token function">c</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>b&#xFF0C;<span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
      <span class="token function">d</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>c&#xFF0C;<span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
        <span class="token function">e</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>d&#xFF0C;<span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
           <span class="token comment">//.....  </span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span>  
      <span class="token punctuation">}</span><span class="token punctuation">)</span>  
    <span class="token punctuation">}</span><span class="token punctuation">)</span>  
  <span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  
</pre><p>&#x8FD9;&#x8FD8;&#x53EA;&#x662F;&#x975E;&#x5E38;&#x7406;&#x60F3;&#x7684;&#x5355;&#x4E00;&#x6570;&#x636E;&#x83B7;&#x53D6;&#x60C5;&#x51B5;&#x4E0B;&#x7684;&#x5D4C;&#x5957;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x5206;&#x652F;&#x5D4C;&#x5957;&#x518D;&#x52A0;&#x4E0A;&#x5F02;&#x5E38;&#x5904;&#x7406;&#xFF0C;&#x90A3;&#x5E72;&#x8106;&#x80FD;&#x4E71;&#x6210;&#x4E00;&#x9505;&#x7CA5;&#x3002;&#x8FD9;&#x5C31;&#x662F;&#x90A3;&#x4E2A;&#x6709;&#x540D;&#x7684;&#x201C;<strong>&#x56DE;&#x8C03;&#x5730;&#x72F1;</strong>&#x201D;&#x3002;<br>
&#x600E;&#x4E48;&#x7834;&#xFF1F;Promise!</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript">a<span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>a<span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>  
  <span class="token keyword">return</span> <span class="token function">b</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>a<span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>b<span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>  
  <span class="token keyword">return</span> <span class="token function">c</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>b<span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>c<span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>  
  <span class="token keyword">return</span> <span class="token function">d</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>c<span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>d<span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>  
  <span class="token keyword">return</span> <span class="token function">e</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>d<span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>e<span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>  
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>result<span class="token operator">-</span><span class="token keyword">from</span><span class="token operator">-</span>e<span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">.</span><span class="token keyword">catch</span><span class="token punctuation">(</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>  
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span><span class="token punctuation">)</span>  

</pre><p>&#x8FD9;&#x6837;&#x8212;&#x5FC3;&#x591A;&#x4E86;&#x5427;&#xFF1F;</p>
<p>&#x6240;&#x4EE5;&#xFF0C;Promise&#x662F;&#x4E2A;&#x5305;&#x88C5;&#x5668;&#xFF0C;&#x628A;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x5305;&#x8D77;&#x6765;&#xFF0C;&#x4EE5;&#x66F4;&#x6613;&#x8BFB;&#x66F4;&#x6709;&#x6761;&#x7406;&#x66F4;&#x7B26;&#x5408;&#x4EBA;&#x7C7B;&#x601D;&#x7EF4;&#x4E60;&#x60EF;&#x7684;&#x65B9;&#x5F0F;&#x8BA9;&#x5E7F;&#x5927;&#x7A0B;&#x5E8F;&#x733F;&#xFF08;&#x5AD2;&#xFF09;&#x6765;&#x5199;&#x5F02;&#x6B65;&#x4EE3;&#x7801;&#x3002;&#x5982;&#x679C;&#x629B;&#x5F00;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x4F7F;&#x7528;Promise&#x5C31;&#x662F;&#x800D;&#x6D41;&#x6C13;&#x3002;<br>
&#x8981;&#x70B9;&#x662F;&#xFF1A;<strong>Promise&#x662F;&#x7528;&#x6765;&#x5305;&#x88C5;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x7684;</strong></p>
<h2 class="mume-header" id="%E5%86%8D%E7%9C%8Basync%E5%87%BD%E6%95%B0">&#x518D;&#x770B;async&#x51FD;&#x6570;</h2>

<p>B:&#x201D;async,&#x5C31;&#x662F;&#x5F02;&#x6B65;&#x7684;&#x610F;&#x601D;&#xFF0C;async&#x51FD;&#x6570;&#xFF0C;&#x5F53;&#x7136;&#x5C31;&#x662F;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x7684;&#x51FD;&#x6570;&#x4E86;&#x3002;&#x8FD9;&#x4E2A;&#x4E0D;&#x5B58;&#x5728;&#x4E8C;&#x4E49;&#x6027;&#x5427;&#xFF1F;&#x201C;<br>
A:&#x201D;&#x8FD9;&#x4E2A;......&#xFF0C;&#x54B1;&#x4EEC;&#x7528;&#x4EE3;&#x7801;&#x8BF4;&#x8BDD;......&#x201C;</p>
<h4 class="mume-header" id="%E5%88%9D%E6%8E%A2async%E5%87%BD%E6%95%B0">&#x521D;&#x63A2;async&#x51FD;&#x6570;</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// &#x5B9A;&#x4E49; async &#x51FD;&#x6570;  </span>
<span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">asynFunction</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;asynFunction begin&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  

  <span class="token comment">// &#x8FD8;&#x662F;&#x7528;&#x4E00;&#x4E2A;for&#x5FAA;&#x73AF;&#x4EE3;&#x8868;&#x5927;&#x6570;&#x636E;&#x91CF;&#x5904;&#x7406;  </span>
  <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> index <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">;</span> index<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>  
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;asynFunction process &apos;</span> <span class="token operator">+</span> index<span class="token punctuation">)</span><span class="token punctuation">;</span>    
  <span class="token punctuation">}</span>  

  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;asynFunction end&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span>  

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;1&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token comment">// &#x8C03;&#x7528; async &#x51FD;&#x6570;  </span>
<span class="token function">asynFunction</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;2&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
</pre><p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>1  
asynFunction begin  
asynFunction process 0  
asynFunction process 1  
asynFunction process 2  
asynFunction process 3  
asynFunction process 4  
asynFunction end  
2  
</code></pre><p>B:&#x201D;&#x8FD9;&#x4E2A;......&#xFF0C;&#x5F02;&#x6B65;&#x51FD;&#x6570;&#x6CA1;&#x6709;&#x5F02;&#x6B65;&#x6267;&#x884C;&#xFF1F;&#x4F1A;&#x4E0D;&#x4F1A;&#x662F;&#x4EC0;&#x4E48;&#x5730;&#x65B9;&#x5199;&#x9519;&#x4E86;&#xFF1F;&#x201C;<br>
A:&#x201D;&#x54C8;&#x54C8;&#xFF0C;&#x52A0;&#x70B9;&#x4E1C;&#x897F;&#x7ED9;&#x4F60;&#x770B;&#x770B;&#x201C;</p>
<h4 class="mume-header" id="await%E5%87%BA%E5%9C%BA">await&#x51FA;&#x573A;</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">asynFunction</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;asynFunction begin&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  

  <span class="token comment">// &#x52A0;&#x5165; await  </span>
  <span class="token keyword">await</span> <span class="token string">&apos;async go!&apos;</span><span class="token punctuation">;</span>  

  <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> index <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> index <span class="token operator">&lt;</span> <span class="token number">5</span><span class="token punctuation">;</span> index<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>  
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;asynFunction process &apos;</span> <span class="token operator">+</span> index<span class="token punctuation">)</span><span class="token punctuation">;</span>    
  <span class="token punctuation">}</span>  

  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;asynFunction end&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span>  

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;1&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token comment">// &#x8C03;&#x7528; async &#x51FD;&#x6570;  </span>
<span class="token function">asynFunction</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;2&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
</pre><p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>1  
asynFunction begin  
2  
asynFunction process 0  
asynFunction process 1  
asynFunction process 2  
asynFunction process 3  
asynFunction process 4  
asynFunction end  
</code></pre><p>B:&quot;&#x4ECE;await&#x5F00;&#x59CB;&#xFF0C;&#x540E;&#x9762;&#x8BED;&#x53E5;&#x90FD;&#x5F02;&#x6B65;&#x4E86;&#xFF1F;&#x96BE;&#x9053;await&#x8868;&#x793A;&#x5F02;&#x6B65;&#x5F00;&#x59CB;&#x7684;&#x610F;&#x601D;&#xFF1F;......&quot;<br>
B:&quot;&#x4E0D;&#x5BF9;&#x554A;&#xFF0C;wait&#x662F;&#x7B49;&#x5F85;&#x7684;&#x610F;&#x601D;&#xFF0C;await&#x660E;&#x660E;&#x662F;&#x7528;&#x6765;&#x7B49;&#x5F85;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x7ED3;&#x679C;&#x7684;&#xFF0C;&#x5728;&#x8FD9;&#x91CC;&#x600E;&#x4E48;&#x53D8;&#x6210;&#x5F02;&#x6B65;&#x5F00;&#x59CB;&#x7684;&#x6807;&#x5FD7;&#x4E86;&#xFF1F;......&quot;<br>
A:&quot;&#x4F60;&#x8BF4;&#x5BF9;&#x4E86;&#xFF0C;await&#x662F;&#x7528;&#x6765;&#x7B49;&#x5F85;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x7ED3;&#x679C;&#x7684;&#x3002;&#x4F46;&#x662F;await&#x5728;&#x4F7F;&#x7528;&#x65F6;&#xFF0C;&#x540E;&#x9762;&#x9700;&#x8981;&#x8DDF;&#x4E00;&#x4E2A;Promise&#x5BF9;&#x8C61;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x662F;&#xFF0C;&#x4F1A;&#x88AB;&#x8F6C;&#x4E3A;Promise&#x5BF9;&#x8C61;&#xFF0C;&#x5982;&#x4E0A;&#x9762;&#x7684;<code>await &apos;async go!&apos;</code>&#x76F8;&#x5F53;&#x4E8E;&#x5982;&#x4E0B;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">await</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> reject<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>  
      <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token string">&apos;async go!&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
    <span class="token punctuation">}</span><span class="token punctuation">)</span>  
</pre><p>A:&#x201D;&#x6240;&#x4EE5;&#xFF0C;await&#x5E76;&#x4E0D;&#x662F;&#x5F02;&#x6B65;&#x5F00;&#x59CB;&#x7684;&#x6807;&#x5FD7;&#xFF0C;&#x800C;&#x662F;&#x56E0;await&#x5BF9;&#x5F02;&#x6B65;&#x6267;&#x884C;&#x7684;&#x7B49;&#x5F85;&#xFF0C;&#x5BFC;&#x81F4;await&#x4E4B;&#x540E;&#x8BED;&#x53E5;&#x5EF6;&#x540E;&#x6267;&#x884C;&#x3002;&#x6211;&#x4EEC;&#x518D;&#x5199;&#x6BB5;&#x4EE3;&#x7801;&#x770B;&#x770B;......&#x201C;</p>
<h4 class="mume-header" id="%E5%BC%95%E5%85%A5promise">&#x5F15;&#x5165;Promise</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">a</span><span class="token punctuation">(</span>arg<span class="token punctuation">)</span><span class="token punctuation">{</span>  
  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> reject<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>  
      <span class="token function">resolve</span><span class="token punctuation">(</span>arg<span class="token punctuation">)</span><span class="token punctuation">;</span>  
    <span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">}</span>  
<span class="token keyword">function</span> <span class="token function">b</span><span class="token punctuation">(</span>arg<span class="token punctuation">)</span><span class="token punctuation">{</span>  
  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> reject<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>  
      <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token string">&apos;&#x4F60;&#x597D;&#xFF0C;&apos;</span> <span class="token operator">+</span> arg<span class="token punctuation">)</span><span class="token punctuation">;</span>  
    <span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">}</span>  

<span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">asynFunction</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
  <span class="token keyword">var</span> aResult <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">a</span><span class="token punctuation">(</span><span class="token string">&apos;&#x5317;&#x4EAC;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
  <span class="token keyword">var</span> bResult <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">b</span><span class="token punctuation">(</span>aResult<span class="token punctuation">)</span><span class="token punctuation">;</span>  

  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>bResult<span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token punctuation">}</span>  

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;1&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token function">asynFunction</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;2&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
</pre><p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>1  
2  
&#x4F60;&#x597D;&#xFF0C;&#x5317;&#x4EAC;  
</code></pre><p>A:&#x201D;&#x5F53;&#x7136;&#xFF0C;&#x6211;&#x4EEC;&#x5F80;&#x5F80;&#x9700;&#x8981;&#x901A;&#x8FC7;async&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x9700;&#x8981;&#x7684;&#x6570;&#x636E;......&#x201C;</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">a</span><span class="token punctuation">(</span>arg<span class="token punctuation">)</span><span class="token punctuation">{</span>  
  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> reject<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>  
      <span class="token function">resolve</span><span class="token punctuation">(</span>arg<span class="token punctuation">)</span><span class="token punctuation">;</span>  
    <span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">}</span>  
<span class="token keyword">function</span> <span class="token function">b</span><span class="token punctuation">(</span>arg<span class="token punctuation">)</span><span class="token punctuation">{</span>  
  <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">Promise</span><span class="token punctuation">(</span><span class="token punctuation">(</span>resolve<span class="token punctuation">,</span> reject<span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>  
      <span class="token function">resolve</span><span class="token punctuation">(</span><span class="token string">&apos;&#x4F60;&#x597D;&#xFF0C;&apos;</span> <span class="token operator">+</span> arg<span class="token punctuation">)</span><span class="token punctuation">;</span>  
    <span class="token punctuation">}</span><span class="token punctuation">)</span>  
<span class="token punctuation">}</span>  

<span class="token keyword">async</span> <span class="token keyword">function</span> <span class="token function">asynFunction</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>  
  <span class="token keyword">var</span> aResult <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">a</span><span class="token punctuation">(</span><span class="token string">&apos;&#x5317;&#x4EAC;&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
  <span class="token keyword">var</span> bResult <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">b</span><span class="token punctuation">(</span>aResult<span class="token punctuation">)</span><span class="token punctuation">;</span>  

  <span class="token comment">// &#x8FD4;&#x56DE;&#x6267;&#x884C;&#x7ED3;&#x679C;  </span>
  <span class="token keyword">return</span> bResult<span class="token punctuation">;</span>  
<span class="token punctuation">}</span>  

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;1&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
<span class="token comment">// &#x9700;&#x8981;&#x5728;then()&#x65B9;&#x6CD5;&#x4E2D;&#x83B7;&#x53D6;&#x6267;&#x884C;&#x7ED3;&#x679C;&#xFF0C;&#x539F;&#x56E0;&#x662F;async&#x51FD;&#x6570;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x540C;&#x6837;&#x4F1A;&#x88AB;&#x5305;&#x88C5;&#x6210;Promise&#x5BF9;&#x8C61;  </span>
<span class="token function">asynFunction</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span>v<span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>v<span class="token punctuation">)</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;2&apos;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  
</pre><p>&#x6267;&#x884C;&#x7ED3;&#x679C;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="" class="language-"><code>1  
2  
&#x4F60;&#x597D;&#xFF0C;&#x5317;&#x4EAC;  
</code></pre><p>async&#x51FD;&#x6570;&#x5176;&#x5B9E;&#x4E5F;&#x662F;&#x4E00;&#x4E2A;&#x5305;&#x88C5;&#x5668;&#xFF0C;async&#x548C;await&#x914D;&#x5408;&#xFF0C;&#x5305;&#x88C5;&#x7684;&#x662F;Promise&#xFF0C;&#x4E0E;Promise&#x76F8;&#x6BD4;&#x6613;&#x8BFB;&#x6027;&#x66F4;&#x597D;&#xFF0C;&#x66F4;&#x52A0;&#x7B26;&#x5408;&#x4EE3;&#x7801;&#x8BED;&#x4E49;&#x3002;<br>
&#x8981;&#x70B9;&#x662F;&#xFF1A;<strong>async&#x51FD;&#x6570;&#x662F;&#x7528;&#x6765;&#x5305;&#x88C5;Promise&#x7684;</strong></p>
<h2 class="mume-header" id="%E6%80%BB%E7%BB%93">&#x603B;&#x7ED3;</h2>

<p>Promise&#x662F;&#x7528;&#x6765;&#x5305;&#x88C5;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x4EC5;&#x4EC5;&#x5305;&#x542B;&#x540C;&#x6B65;&#x4EE3;&#x7801;&#x5B83;&#x662F;&#x5F02;&#x6B65;&#x4E0D;&#x4E86;&#x6EF4;&#x3002;<br>
Promise&#x628A;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x5305;&#x88C5;&#x8D77;&#x6765;&#xFF0C;&#x662F;&#x4E3A;&#x4E86;&#x8BA9;&#x4F60;&#x7684;&#x5F02;&#x6B65;&#x4EE3;&#x7801;&#x770B;&#x8D77;&#x6765;&#x66F4;&#x76F4;&#x89C2;&#x66F4;&#x4F18;&#x96C5;&#x3002;</p>
<p>async&#x51FD;&#x6570;&#x662F;&#x7528;&#x6765;&#x5305;&#x88C5;Promise&#x7684;&#xFF0C;&#x6240;&#x4EE5;&#x4EC5;&#x4EC5;&#x5305;&#x542B;&#x540C;&#x6B65;&#x4EE3;&#x7801;&#x5B83;&#x4E5F;&#x662F;&#x5F02;&#x6B65;&#x4E0D;&#x4E86;&#x6EF4;&#x3002;<br>
async&#x51FD;&#x6570;&#x628A;Promise&#x5305;&#x88C5;&#x8D77;&#x6765;&#xFF0C;&#x662F;&#x4E3A;&#x4E86;&#x8BA9;&#x4F60;&#x7684;&#x5F02;&#x6B65;&#x4EE3;&#x7801;&#x770B;&#x8D77;&#x6765;&#x6BD4;Promise&#x8FD8;&#x8981;&#x76F4;&#x89C2;&#x8FD8;&#x8981;<br>
&#x4F18;&#x96C5;&#xFF0C;&#x80FD;&#x591F;&#x505A;&#x5230;&#x671B;&#x6587;&#x751F;&#x4E49;......</p>
<p>&#x672C;&#x6587;&#x7684;&#x521D;&#x8877;&#x5176;&#x5B9E;&#x662F;&#x5E0C;&#x671B;&#x5927;&#x5BB6;&#x4E0D;&#x8981;&#x671B;&#x6587;&#x751F;&#x4E49;......&gt;_&lt;</p>
<h2 class="mume-header" id="%E9%A2%98%E5%A4%96%E8%AF%9D">&#x9898;&#x5916;&#x8BDD;</h2>

<ul>
<li>&#x4E3A;&#x4EC0;&#x4E48;&#x793A;&#x4F8B;&#x4E2D;&#x7684;&#x5F02;&#x6B65;&#x64CD;&#x4F5C;&#x90FD;&#x5728;&#x4E3B;&#x7EBF;&#x4EE3;&#x7801;&#x4E4B;&#x540E;&#x6267;&#x884C;&#xFF1F;<br>
&#x56E0;&#x4E3A;event-loop,&#x4E0D;&#x4E86;&#x89E3;&#x70B9;<a href="https://pan.baidu.com/s/1tIjs5zZ1a_P2cHDQ9UgjJA">&#x8FD9;&#x91CC;</a>(&#x5BC6;&#x7801;&#xFF1A;yc3r)</li>
<li>&#x4E3A;&#x4EC0;&#x4E48;Promise&#x793A;&#x4F8B;&#x4E2D;&#x603B;&#x662F;&#x6709;&#x4E00;&#x4E2A;reject<br>
&#x5F53;&#x53D1;&#x751F;&#x9519;&#x8BEF;&#x3001;&#x5F02;&#x5E38;&#xFF0C;&#x672A;&#x83B7;&#x53D6;&#x5230;&#x6570;&#x636E;&#x7B49;&#x60C5;&#x51B5;&#x65F6;&#x4F1A;&#x7528;&#x5230;&#x5B83;&#xFF0C;&#x4E0D;&#x4E86;&#x89E3;&#x70B9;<a href="http://es6.ruanyifeng.com/#docs/promise">&#x8FD9;&#x91CC;</a></li>
<li>&#x4E3A;&#x4EC0;&#x4E48;async&#x51FD;&#x6570;&#x4E2D;&#x7684;await&#x53EF;&#x4EE5;&#x7B49;&#x5F85;<br>
&#x56E0;&#x4E3A;&#x5B83;&#x4EEC;&#x662F;generator&#x7684;&#x8BED;&#x6CD5;&#x7CD6;&#xFF0C;&#x4E0D;&#x4E86;&#x89E3;&#x70B9;<a href="http://es6.ruanyifeng.com/#docs/generator">&#x8FD9;&#x91CC;</a></li>
</ul>

      